package com.powerbank.adminsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.powerbank.adminsystem.entity.AdminOperationLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作日志Mapper接口
 */
@Mapper
public interface AdminOperationLogMapper extends BaseMapper<AdminOperationLog> {

    /**
     * 根据用户ID查询操作日志
     */
    @Select("SELECT * FROM admin_operation_log WHERE user_id = #{userId} ORDER BY created_time DESC LIMIT #{limit}")
    List<AdminOperationLog> findByUserId(@Param("userId") Long userId, @Param("limit") Integer limit);

    /**
     * 根据模块查询操作日志
     */
    @Select("SELECT * FROM admin_operation_log WHERE module = #{module} ORDER BY created_time DESC LIMIT #{limit}")
    List<AdminOperationLog> findByModule(@Param("module") String module, @Param("limit") Integer limit);

    /**
     * 查询最近的操作日志
     */
    @Select("SELECT * FROM admin_operation_log ORDER BY created_time DESC LIMIT #{limit}")
    List<AdminOperationLog> findRecentLogs(@Param("limit") Integer limit);
}